﻿using System;
using System.Buffers;
using Beefly.Json.Extensions;
using Beefly.Json.Meta;

namespace Beefly.Json.Formats;

sealed class Array1JsonFormat<T> : AJsonArrayFormat1<T>
{
    public override void SerializeArray(IBufferWriter<char> writer, ref T[] item)
    {
        var format = JsonMeta.GetArrayFormat<T>(1) as AJsonFormat<T>;
        
        writer.WriteArrayBeginChar();
        if (item != null)
        {
            for (int i = 0; i < item.Length; i++)
            {
                var value = item[i];
                format.Serialize(writer, ref value);
            }
        }
        writer.WriteArrayEndChar();
    }

    public override T[] DeserializeArray(in Span<char> str)
    {
        var span = str.Slice(1, str.Length - 2);
        str.IndexOf(JsonSymbol.COMMA);
        
        
        
        
        throw new NotImplementedException();
    }
}